import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../base/base_app.dart';

/// 创建人： Created by zhaolong
/// 创建时间：Created by  on 2021/9/25.
///
/// gongzhonghao biglead
/// https://study.163.com/instructor/1021410098.htm
/// https://blog.csdn.net/zl18603543572
/// https://www.toutiao.com/c/user/token/MS4wLjABAAAAYMrKikomuQJ4d-cPaeBqtAK2cQY697Pv9xIyyDhtwIM/
///
///
///

//应用入口
void main() {
  ///启动根目录
  runApp(BaseApp(
    homeWidget: Example410(),
  ));
}

///代码清单 4-17
///lib/code/code4/example_410_imageshow_page.dart
///图片浏览器
class Example410 extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _ExampleState();
  }
}

class _ExampleState extends State<Example410> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Stepper"),
      ),
      backgroundColor: Colors.white,
      body: SizedBox(
        width: 240,
        child: buildSegment(),
      ),
    );
  }

  ///Stepper 是 flutter 提供的步骤选择器

  //当前选中的索引
  buildSegment() {
    return Stepper(
      physics: const BouncingScrollPhysics(),
      //滑动的物理效果
      //Stepper 类型，分为横向与纵向两种，默认为 StepperType.vertical
      type: StepperType.vertical,
      //当前 step，默认为 0
      currentStep: 0,
      //step 点击回调函数
      // onStepTapped: (int index){},
      //Next 按钮点击回调函数
      onStepContinue: () {},
      //Cancel 按钮点击回调函数
      //onStepCancel: (){},
      elevation: 10,
      controlsBuilder: (BuildContext context, ControlsDetails details) {
        return Row(
          children: <Widget>[
            TextButton(
              onPressed: details.onStepContinue,
              child: Text('next'),
            ),
            TextButton(
              onPressed: details.onStepCancel,
              child: Text('back'),
            ),
          ],
        );
      },
      steps: const <Step>[
        Step(
            isActive: true,
            state: StepState.error,
            title: Text('2020-4-23'),
            content: Text('今天是2020-4-23'),
            subtitle: Text('该去摸鱼了')),

        Step(title: Text('2020-4-24'), content: Text('今天是2020-4-24')),
        Step(title: Text('2020-4-25'), content: Text('今天是2020-4-25')),
      ],
    );
  }
}
